package seminar.evaluate;

import seminar.Semester;

/**
 * Evaluate start and end of lectures
 * @author Johannes Degler
 *
 */
public class StartAndEndEvaluator implements IEvaluator{

	private int calcEndingPoints(final int end){
		switch(end){
		case 4:
			return 10;
		case 5:
			return -2;
		case 6:
			return -10;
		default:
			return 0;
		}
	}

	private int calcStartingPoints(final int start){
		switch(start){
		case 1: //First slot?
			return -8;
		case 2: //Second slot
			return -2;
		case 5:
			return -8;
		case 6:
			return -15;
		default:
			return 0;
		}
	}

	@Override
	public int getPoints(final Semester semester) {
		int points = 0;

		//Get starting slots
		for(int day = 0; day < 5; day++){
			int start = 1;
			for(int slot = 0; slot < 6; slot++)
				if(semester.getEvents()[day][slot] == null)
					start++;
				else
					break;
			points += this.calcStartingPoints(start);
		}

		//Get ending point
		for(int day = 0; day < 5; day++){
			if(semester.getEvents()[day][5] != null){
				points += this.calcEndingPoints(6);
				continue;
			}

			for(int slot = 5; slot >= 0 ; slot--)
				if(semester.getEvents()[day][slot] != null){
					points += this.calcEndingPoints(slot+1);
					break;
				}
		}

		return points;
	}

}
